/**
 *  js工具方法集
 *  @author ZZB
 */
function isEmpty(e){
    var value;
    if(e instanceof jQuery){
        value = jQueryElementToObject(e);
    }
    else value = e;
    return value == undefined || value == null;
}
function isNotEmpty(e){
    return ! isEmpty(e);
}
function isBlank(e){
    var value;
    if(e instanceof jQuery){
        value = e.val();
    }else value = e;
    return value == undefined || value == null || value == '';
}
function isNotBlank(e) {
    return ! isBlank(e);
}
function isZero(e){
    var value;
    if(e instanceof jQuery){
        value = e.val();
    }else value = e;
    if( ! value instanceof Number){
        value = parseFloat(value);
    }
    return value == undefined || value == null || value == 0;
}
function isNotZero(e){
    return ! isZero(e);
}

function toPosReal(f){
    if(isNaN(f)){
        return "0.00";
    }
    if(typeof (f) != "number"){
        f = parseFloat(f);
    }
    return f.toFixed(2);
}

function jQueryElementToObject(e){
    var $els;
    if(e instanceof jQuery)$els = e;
    else $els = $(e);
    var object = null;
    if($els.length > 0){
        object = {};
        $els.each(function(i,e){
            var name = $(e).attr('name');
            var value = $(e).val();
            if(eval("object."+name+" == undefined")){
                eval("object."+name+" = value;");
            }else {
                if(!eval('object.'+name+' instanceof Array')){
                    var tmp = eval('object.'+name);
                    eval('object.'+name+' = new Array();');
                    eval('object.'+name+'[0] = tmp;');
                }
                var next = eval('object.'+name+".length;");
                eval('object.'+name+'[next] = value;');
            }
        });
    }
    return object;
}

function collectionLength(array){
    if(typeof(array) == "object"){
        return array.length;
    }
    return 0;
}